from flask import Blueprint, session, redirect, render_template
from utils import db

od = Blueprint('order', __name__)

@od.route('/order/list')
def order_list():
    session_info = session.get('user_info')
    role = session_info['role']  # 1-普通用户 2-管理员
    
    if role == 1:
        # select * from order where user_id = session_info['id]
        data_list = db.fetch_all('select * from `order` where user_id = %s', [session_info['id']])
        
    else:
        # select * from order
        data_list = db.fetch_all('select * from `order`', [])
    print(data_list)    
    return render_template('oder_list.html', data_list=data_list)

@od.route('/create/list')
def create_list():
    
    return "创建订单"